Chase
Program Description Chase is a simple yet enjoyable game. In it, players take the role of a "greater-than" symbol (>) who is hungry to eat some X's. It is played on the regular typing screen, and there are 6 characters that can move around the screen. One is the player's character, the > sign. Another, the X, is the character that the player is supposed to move towards and eat once he has reached it. The other four, however, are "not-equal-to" symbols (≠) which are vicious and will try to eat the player if they get close enough. Chase has a title screen that draws itself up on the Graph screen through the CSTART program, which must also be on a player's calculator before he can play Chase. The title screen has four options which are: 1) New Game (to start a new game) 2) Continue (to continue a currently saved game) 3) Instructions (to bring up the instructions for Chase) 4) Quit (to leave the program and return to the main screen). In the Instructions page, much of the above information is covered, as well as other information like which keys are used for the game controls. In the game, the five non-player characters (the four ≠'s and the X) move around on their own, randomly following any of four patterns. For instance, if one of the ≠'s moves a space left, then another will move up, another will move down, and another will move right. Two ≠'s will never move in the same direction as one another in one move. Also, the movement of the X will parallel that of one of the four monsters. The controls that the player uses to move are displayed on the Instructions page. The player can press any of the 9 number keys (1-9) except for the 5 to move his character. For instance, pressing the 7 key will move the player's character up one space and to the left one space, and pressing the 8 key will only move the player's character up one space. This explanation may be difficult to understand but is very easy to figure out by playing the game. The player's score is displayed in the upper-right corner of the screen throughout the game. Whenever the player eats the X character, one point will be added to his score in the display. Also, the X will disappear and be regenerated somewhere else on the screen. The player's high score is displayed in the Chase title screen every time he starts the game. One last control is the ENTER key, which pauses/saves the game that you are currently playing. If the player presses it once while he's playing, he can save his game and come back to it whenever he wishes by starting prgmCHASE and choosing option 2, Continue, mentioned above. Also, by pressing the ENTER key twice while playing, once to pause/save the game and then once again, He can resume immediately and play will continue. The effects of this are that all of the variables for things like score and position of each character on the screen are stored and also, the game will regain its regular running speed. Unfortunately, whenever one is running a TI-Basic program that repeats, it will eventually run slower and slower. To avoid or solve this problem when playing Chase, one can use this method of pressing ENTER twice. As stated above, this exits the program and then resumes it again. Note: The variables used by the calculator to operate Chase are stored in the J matrix. Program Code Notes: #Many of these lines of code can be linked together in one line by just typing a ":" instead of pressing ENTER and typing the next command on the next line. Also, some of the commands displayed here are already linked in this way. #The "•" found in the command, " :Output(8,3,"-GAME•SAVED- ", is actually a very small square and it can be found in the CATALOG menu on your calculator. It will be above what looks like a small plus sign (+), near the bottom of the list. PROGRAM:CHASE :If Ans=105:1→Y :{3,9→dim(J :J(1,1→C:J(1,2→D:J(1,3→E:J(1,4→F:J(2,1→G:J(2,2→H :J(2,3→I:J(2,4→J:J(3,1→K:J(3,2→L:J(3,3→M:J(3,4→N :If 1=Y :Then :DelVar Y :J(2,5→X :Goto A :End :If 1≠J(3,5 :0→J(1,5 :prgmCSTART :ZStandard :AxesOn :If Ans=93 :Then :J(2,5→X :Goto A :End :DelVar X :round(C,0→C:round(D,0→D:round(E,0→E:round(F,0→F:round(G,0→G:round(H,0→H :round(I,0→I:round(J,0→J:round(K,0→K:round(L,0→L:round(M,0→M:round(N,0→N :C+round(9rand,0)-round(9rand,0→C:D+round(9rand,0)-round(9rand,0→D :G+round(4rand,0)-round(4rand,0→G:H+round(4rand,0)-round(4rand,0→H :I+round(4rand,0)-round(4rand,0→I:J+round(4rand,0)-round(4rand,0→J :K+round(4rand,0)-round(4rand,0→K:L+round(4rand,0)-round(4rand,0→L :M+round(4rand,0)-round(4rand,0→M:N+round(4rand,0)-round(4rand,0→N :Lbl E :If C<1:1→C:If C>8:8→C:If D<1:1→D:If D>16:16→D:If E<2:2→E:If E>7:7→E :If F<2:2→F:If F>15:15→F:If G<2:2→G:If G>7:7→G:If H<2:2→H:If H>15:15→H :If I<2:2→I:If I>7:7→I:If J<2:2→J:If J>15:15→J:If K<2:2→K:If K>7:7→K :If L<2:2→L:If L>15:15→L:If M<2:2→M:If M>7:7→M:If N<2:2→N:If N>15:15→N :If C=E and D=F or C=G and D=H or C=I and D=J or C=K and D=L or C=M and D=N :Then :D+round(6rand,0)-round(3rand,0→D :Goto E :End :Lbl C :E+round(9rand,0)-round(9rand,0→E :F+round(9rand,0)-round(9rand,0→F :If E<2:2→E:If E>7:7→E:If F<2:2→F:If F>15:15→F :If E=M and F=N :Goto C :Lbl A :ClrHome :Disp X :Output(E,F,"X :Output(G,H,"≠ :Output(I,J,"≠ :Output(K,L,"≠ :Output(M,N,"≠ :Output(C,D,"> :If C=E and D=F :Then :X+1→X :Goto C :End :If C=G and D=H or C=I and D=J or C=K and D=L or C=M and D=N :Goto D :getKey :If Ans=105 :Then :Output(8,3,"...SAVING... :C→J(1,1 :D→J(1,2 :E→J(1,3 :F→J(1,4 :G→J(2,1 :H→J(2,2 :I→J(2,3 :J→J(2,4 :K→J(3,1 :L→J(3,2 :M→J(3,3 :N→J(3,4 :X→J(3,5 :Output(8,3,"-GAME•SAVED- :105 :Stop :End :If Ans=0 :Goto B :If Ans=72 and C>1 and D>1 :Then :C-1→C :D-1→D :End :If Ans=73 and C>1 :C-1→C :If Ans=74 and C>1 and D<16 :Then :C-1→C :D+1→D :End :If Ans=82 and D>1 :D-1→D :If Ans=84 and D<16 :D+1→D :If Ans=92 and C<8 and D>1 :Then :C+1→C :D-1→D :End :If Ans=93 and C<8 :C+1→C :If Ans=94 and C<8 and D<16 :Then :C+1→C :D+1→D :End :Lbl B :randInt(1,4 :If Ans=4 :Goto 3 :If Ans=3 :Goto 2 :If Ans=2 :Goto 1 :If F≥2 and G≤7 and J≤15 and K≥2 and N≥2 :Then :F-1→F :G+1→G :J+1→J :K-1→K :N-1→N :Goto A :End :Lbl 1 :If E≥2 and H≥2 and I≤7 and L≤15 and M≥2 :Then :E-1→E :H-1→H :I+1→I :L+1→L :M-1→M :Goto A :End :Lbl 2 :If F≤15 and G≥2 and J≥2 and K≤7 and N≤15 :Then :F+1→F :G-1→G :J-1→J :K+1→K :N+1→N :Goto A :End :Lbl 3 :If E≤7 and H≤15 and I≥2 and L≥2 and M≤7 :Then :E+1→E :H+1→H :I-1→I :L-1→L :M+1→M :End :Goto A :Lbl D :Output(4,2,"YOU GOT EATEN! :1→J(3,5 :0→J(2,5 :If X>J(1,5 :Then :Output(5,2,"{Press enter} :Pause :X→J(1,5 :Output(4,2,"New high score: :Output(5,2," " <-- (This close-quote mark is not needed, but :Output(5,8,J(1,5 there must be 14 blank spaces here) Category:TI-Basic_Programs (wikibook) Category:Programing Examples